import { _decorator, Component, Node, Vec3, tween } from 'cc';
const { ccclass, property } = _decorator;

/**
 * https://docs.cocos.com/creator/manual/zh/tween/tween-interface.html
 */
@ccclass('TweenUtil')
export class TweenUtil extends Component {
    /**
     * 移动
     * @param node 
     * @param pt 
     * @param fn 
     * @param tweenDuration 
     */
    public static moveTo(node:Node, pt:Vec3, fn:Function, tweenDuration:number):void{
        tween(node.position).to(tweenDuration, pt, {
            onComplete(target) {
                if(null != fn) fn();
            },
        }).start();
    }
}

